/* 
 * File:   SockStreamAsincronico.cpp
 * Author: max
 * 
 * Created on June 1, 2013, 3:06 PM
 */

#include "server_SockStreamAsincronico.h"
#include "server_SockEndPointAsincronico.h"
using namespace TP::Comunicacion::Asincronica;

SockStreamAsincronico::SockStreamAsincronico(){
    _socket = new SockStream();
}

SockStreamAsincronico::SockStreamAsincronico(int pDomain, int pProtocol){
    _socket = new SockStream (pDomain, pProtocol);
}

SockStreamAsincronico::~SockStreamAsincronico(){
    delete _socket;
}

void SockStreamAsincronico::Iniciar () throw (Excepcion&){
    try
    {
        _socket->Iniciar();
    }
    catch (Excepcion &ex)
    {
        throw;
    }
}

void SockStreamAsincronico::Finalizar() throw (Excepcion&){
    try
    {
        _socket->Finalizar();
    }
    catch (Excepcion &ex)
    {
        throw;
    }
}

void SockStreamAsincronico::Bind(string& pPuerto, uint32_t pInAddr) throw (Excepcion&){
    try
    {
        _socket->Bind( pPuerto, pInAddr);
    }
    catch (Excepcion &ex)
    {
        throw;
    }
}

void SockStreamAsincronico::Listen(int pQueueLength) throw (Excepcion&){
    try
    {
        _socket->Listen(pQueueLength);
    }
    catch (Excepcion &ex)
    {
        throw;
    }
}

SockEndPointAsincronico* SockStreamAsincronico::Acept () throw (Excepcion&){
    try
    {
        SockEndPointAsincronico* endPoint = (SockEndPointAsincronico*) new SockEndPointAsincronico(_socket->Acept());
        return endPoint;
    }
    catch (Excepcion &ex)
    {
        throw;
    }
}

